<!DOCTYPE html>
<!--支付成功页面-->
<html lang="zh">
<head>
    <meta name="applicable-device" content="pc">
    <meta charset="utf-8">
    <link rel="stylesheet" href="/home/css/book/layer.css"/>
    <link href="/home/css/style.css" rel="stylesheet" type="text/css"/>
    <link href="/home/css/common.css" rel="stylesheet" type="text/css"/>
    <link rel="stylesheet" type="text/css" href="/home/css/tk_order.css">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>支付成功页面_中国梦想游网</title>
    <script type="text/javascript" src="/home/js/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="/home/js/jquery-3.5.1.js"></script>
    <script type="text/javascript" src="/home/js/axios.js"></script>
    <script type="text/javascript" src="/home/js/config.js"></script>
    <style type="text/css">
        .ka {
            padding-left: 10px;
            margin-top: 10px;
            padding-top: 20px;
            font-size: 23px;
            font-family: "华文行楷";
            background-color: #ECECFF;
            font-size: 23px;
        }

        .order_content {
            height: 94px;
        }

        .footer_w {
            width: 100%;
            background: none repeat scroll 0% 0% #000;
            padding: 15px 0px;

        }

        .footer .footer_c {
            float: left;
            padding-top: 20px;
        }

        .footer .f_logo {
            float: right;
            margin-top: -53px;
        }

        .footer .footer_c a {
            color: #fff;
        }

        .footer {
            width: 980px;
            margin: 0 auto;
            color: #fff;
        }
    </style>

    <!-- 移除顶部模拟数据脚本，统一使用底部axios逻辑加载与渲染 -->
</head>
<body class="index1200">
<!--引入顶部header.html文件-->
<div id="header"></div>
<!-- 订单信息服务 -->
<div class="resule-block succ-block">
    <div class="result-txt">
        <div class="order_box" id="J_Ticket">
            <span class="order_title">订单信息</span>
            <span style="display: inline-block">订单编号：</span>
            <span style="display: inline-block ;color:orangered;"><span class="order_no">20240420123456789</span></span>
            <span style="margin-left: 150px;">车票人数：</span>
            <span style="margin-left: 6px; font-size: 18px; color: orangered;"><span
                    class="ticket_count">2</span>人</span>
            <span style="margin-left: 235px;">付款金额：</span>
            <span style="margin-left: 6px; font-size: 20px; color: orangered;">￥<span class="total_price">280.00</span></span>
            <div id="center">
                <!-- 单程 -->
                <div id="dancheng">
                    <div class="order_content">
                        <!--ticket detail info S-->
                        <div class="train_detail clearfix">
                            <div class="train_name">
                                <div class="train_num" style="margin-top: -28px;font-size: 20px;color: #ed9191">乘车日期：<span
                                        class="departure_date">2024-04-25</span></div>
                                <div class="train_det_date" style="color: orangered;">
                                </div>
                            </div>
                            <div class="train_date_start">
                                <strong class="train_det_time"><span class="start_time">08:30</span></strong>
                                <span class="train_det_station"><span class="start_station">北京西</span><i
                                        class="icon "></i></span>
                            </div>
                            <div class="train_duration">
                                <div class="train_duration_left"></div>
                                <strong class="train_duration_time"><span class="train_number">G101</span></strong>
                                <div class="train_duration_right"></div>
                                <div class="train_icon"></div>
                            </div>
                            <div class="train_date_end">
                                <strong class="train_det_time"><span class="arrive_time">12:45</span></strong>
                                <span class="train_det_station"><span class="end_station">上海虹桥</span><i
                                        class="icon icon_end"></i></span>
                            </div>
                        </div>
                        <!--ticket detail info E-->
                        <!--ticket seat type S-->
                        <div class="train_types clearfix">
                            <div class="J_TrainType train_type  selected"
                                 data_resId="1425125366"
                                 style="margin-left: 543px; margin-top: -118px;">
                                <table>
                                    <tr>
                                        <td class="td1"
                                            style="text-align: center;font-size: 20px; font-family: cursive;">售票成功
                                        </td>
                                    </tr>
                                </table>
                            </div>
                        </div>
                    </div>
                    <div class="foot" style="margin-bottom: 23px; margin-left: 28px;font-size: 15px;">
                    </div>
                </div>
                <!--  往返-->
                <div id="wangfan" style="display:none;">
                    <div class="order_content" style="height: 127px;">
                        <!--ticket detail info S-->
                        <div class="train_detail clearfix">
                            <div class="train_name">
                                <div class="train_num"
                                     style="font-size: 21px; margin-top: -40px; margin-bottom: 14px; color: skyblue;">往
                                </div>
                                <div class="train_num">G101</div>
                                <div class="train_det_date" style="color: orangered;">
                                </div>
                            </div>
                            <div class="train_date_start">
                                <strong class="train_det_time">08:30</strong> <span
                                    class="train_det_station">北京西<i class="icon "></i></span> <span
                                    class="train_det_date">2024-04-25 <br/>星期四
							</span>

                            </div>
                            <div class="train_duration">
                                <div class="train_duration_left"></div>
                                <strong class="train_duration_time">04:15</strong>
                                <div class="train_duration_right"></div>
                                <div class="train_icon"></div>
                            </div>
                            <div class="train_date_end">
                                <strong class="train_det_time">12:45</strong> <span
                                    class="train_det_station">上海虹桥<i class="icon icon_end"></i></span>
                                <span class="train_det_date"> 2024-04-25<br/>星期四
							</span>

                            </div>
                        </div>
                        <!--ticket detail info E-->
                        <!--ticket seat type S-->
                        <div class="train_types clearfix">
                            <div class="J_TrainType train_type  selected"
                                 data_resId="1425125366"
                                 style="margin-left: 543px; margin-top: -118px;">
                                <table>
                                    <tr>
                                        <td class="td1 ">二等座</td>
                                        <td class="seat_price">￥140.00</td>
                                    </tr>
                                </table>
                            </div>

                        </div>
                        <div id="dan" style="margin-top: -25px;"></div>
                    </div>
                    <div class="order_content" style="height: 105px;">
                        <!--ticket detail info S-->
                        <div class="train_detail clearfix">
                            <div class="train_name">
                                <div class="train_num"
                                     style="font-size: 21px; margin-top: -40px; margin-bottom: 14px; color: skyblue;">返
                                </div>
                                <div class="train_num">G102</div>
                                <div class="train_det_date" style="color: orangered;">
                                </div>
                            </div>
                            <div class="train_date_start">
                                <strong class="train_det_time">14:30</strong> <span
                                    class="train_det_station">上海虹桥<i class="icon "></i></span> <span
                                    class="train_det_date">2024-04-30 <br/>星期二
							</span>

                            </div>
                            <div class="train_duration">
                                <div class="train_duration_left"></div>
                                <strong class="train_duration_time">04:20</strong>
                                <div class="train_duration_right"></div>
                                <div class="train_icon"></div>
                            </div>
                            <div class="train_date_end">
                                <strong class="train_det_time">18:50</strong> <span
                                    class="train_det_station">北京西<i class="icon icon_end"></i></span>
                                <span class="train_det_date"> 2024-04-30<br/>星期二
							</span>
                            </div>
                        </div>
                        <!--ticket detail info E-->
                        <!--ticket seat type S-->
                        <div class="train_types clearfix">
                            <div class="J_TrainType train_type  selected"
                                 data_resId="1425125366"
                                 style="margin-left: 543px; margin-top: -118px;">
                                <table>
                                    <tr>
                                        <td class="td1 ">二等座</td>
                                        <td class="seat_price">￥140.00</td>
                                    </tr>

                                </table>
                            </div>

                        </div>
                        <div id="fan" style="margin-top: -25px;"></div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="result-tips">
        <span class="success-icon"></span>
        <p class="result-tip">恭喜您&nbsp;<span class="user_name"></span>，订单支付成功！</p>
        <div class="result-tip-submit ">
            <a class="result-tip-return" href="/home/index.html" m="点击_返回首页_1052579652"/>返回首页 </a>
<!--            <a id="J_checkOrder" class="result-tip-check" href="" m="点击_查询订单_1052579652"/>-->
<!--            查看订单 </a>-->
        </div>
    </div>
</div>

<!-- 以下为静态信息 -->
<div class="local-block succ-block server-block">
    <p class="server-tit">
        <span><em>本地服务</em></span>
    </p>
    <ul class="clearfix">
        <li><a href="https://touch.qunar.com/hotelindex" m="点击_出行服务_酒店_1052579652">
            <span class="succ-icon">
                <img src="https://m.tuniucdn.com/fb2/t1/G1/M00/95/BA/Cii-U1i44euIeqbFAAASdRBYynIAAIQygOoNMoAABKN264.png"/></span>
            <div class="mess">
                <div class="price">
                    <span class="s-name" style="margin-top: 5px">酒店民宿</span>
                    <span class="pri" style="margin-top: 3px">实时查询</span>
                </div>
            </div>
        </a></li>
        <li><a href="https://piao.qunar.com/overseas/" m="点击_出行服务_门票_1052579652"> <span
                class="succ-icon"><img
                src="https://m.tuniucdn.com/fb2/t1/G1/M00/95/BA/Cii9EFi44euIYXN4AAAVefk5010AAIQygOsNRUAABWR758.png"/></span>
            <div class="mess">
                <div class="price">
                    <span class="s-name" style="margin-top: 5px">景点门票</span>
                    ¥ <em>15</em><i>起</i>
                </div>
            </div>
        </a>
        </li>
        <li><a href="https://touch.qunar.com/hotelindex" m="点击_出行服务_酒店_1052579652">
            <span class="succ-icon">
                <img src="https://m.tuniucdn.com/fb2/t1/G1/M00/95/BA/Cii-U1i44euIeqbFAAASdRBYynIAAIQygOoNMoAABKN264.png"/></span>
            <div class="mess">
                <div class="price">
                    <span class="s-name" style="margin-top: 5px">特色美食</span>
                    <span class="pri" style="margin-top: 3px">实时查询</span>
                </div>
            </div>
        </a></li>
        <li><a href="https://touch.qunar.com/hotelindex" m="点击_出行服务_酒店_1052579652">
            <span class="succ-icon">
                <img src="https://m.tuniucdn.com/fb2/t1/G1/M00/95/BA/Cii-U1i44euIeqbFAAASdRBYynIAAIQygOoNMoAABKN264.png"/></span>
            <div class="mess">
                <div class="price">
                    <span class="s-name" style="margin-top: 5px">景点攻略</span>
                    <span class="pri" style="margin-top: 3px">在线查看</span>
                </div>
            </div>
        </a></li>
    </ul>
</div>

<div id="scroll0" class="succ-block pro-block ">
    <div class="pro-tit clearfix">
        <span class="tit"> <i></i> 酒店
        </span> <a href="#" class="link" m="点击_更多酒店单品推荐_更多酒店">更多酒店 &gt;</a>
    </div>
    <ul class="clearfix">
        <li>
            <div class="pro-box ">
                <a href="#" m=点击_酒店_1-200294006_1052579652>
                    <div class="img-box">
                        <img src="https://m.tuniucdn.com/fb2/t1/G1/M00/36/15/Cii-U1ku7XWIYEiaAAIYOmAZYxIAALKmQAKuA4AAhhS587_w450_h300_c1_t0.jpg"/>
                        <div class="dess-txt clearfix">
                            <span class="dess-satisf fl"> <i>高档型</i>
                            </span> <span class="dess-rated fr"> <i>44</i> 条评价
                            </span>
                        </div>
                    </div>
                    <div class="content-box">
                        <p class="content-tit">香巴拉雅酒店</p>
                        <div class="content-txt clearfix">
                            <div class="content-price fl">
                                <span class="unit">¥</span> <span class="num">266</span> <span
                                    class="text">起</span>
                            </div>
                            <div class="content-detail fr">
                                <span> <i>距离火车站约1.9km</i>
                                </span>
                            </div>
                        </div>
                    </div>
                </a>
            </div>
        </li>
        <li>
            <div class="pro-box ">
                <a href="#" m=点击_酒店_2-2276280_1052579652>
                    <div class="img-box">
                        <img
                                src="https://m4.tuniucdn.com/filebroker/cdn/res/d6/e5/d6e525d00ec9e119f5325c89d6842035_w450_h300_c1_t0.jpg"/>
                        <div class="dess-txt clearfix">

                            <span class="dess-satisf fl"> <i>二星级</i>
                            </span> <span class="dess-rated fr"> <i>32</i> 条评价
                            </span>
                        </div>
                    </div>
                    <div class="content-box">

                        <p class="content-tit">宜家商务酒店</p>
                        <div class="content-txt clearfix">
                            <div class="content-price fl">

                                <span class="unit">¥</span> <span class="num">98</span> <span
                                    class="text">起</span>
                            </div>
                            <div class="content-detail fr">

                                <span> <i>距离火车站约2.6km</i>
                                </span>
                            </div>
                        </div>
                    </div>
                </a>
            </div>
        </li>
        <li>
            <div class="pro-box ">
                <a href="#" m=点击_酒店_3-1689299713_1052579652>
                    <div class="img-box">
                        <img src="https://m.tuniucdn.com/fb2/t1/G4/M00/0F/65/Cii-VVmdjT6IOKIdAAFeZEF3w_MAAAVdQP8AS8AAV58938_w450_h300_c1_t0.jpg"/>
                        <div class="dess-txt clearfix">
                            <span class="dess-satisf fl"> <i>二星级</i>
                            </span> <span class="dess-rated fr"> <i>8</i> 条评价
                            </span>
                        </div>
                    </div>
                    <div class="content-box">
                        <p class="content-tit">尚客优连锁酒店</p>
                        <div class="content-txt clearfix">
                            <div class="content-price fl">
                                <span class="unit">¥</span> <span class="num">139</span> <span
                                    class="text">起</span>
                            </div>
                            <div class="content-detail fr">
                                <span> <i>距离火车站约2.1km</i>
                                </span>
                            </div>
                        </div>
                    </div>
                </a>
            </div>
        </li>
        <li>
            <div class="pro-box ">
                <a href="#" m=点击_酒店_4-219479413_1052579652>
                    <div class="img-box">
                        <img
                                src="https://m.tuniucdn.com/fb2/t1/G4/M00/2E/0D/Cii-VVmva8uILHrwAAG3JcC1DEUAAA4nAGzN74AAbc9909_w450_h300_c1_t0.jpg"/>

                        <div class="dess-txt clearfix">

                            <span class="dess-satisf fl"> <i>二星级</i>
                            </span> <span class="dess-rated fr"> <i>3</i> 条评价
                            </span>

                        </div>
                    </div>
                    <div class="content-box">

                        <p class="content-tit">华兰商务酒店</p>

                        <div class="content-txt clearfix">
                            <div class="content-price fl">

                                <span class="unit">¥</span> <span class="num">119</span> <span
                                    class="text">起</span>

                            </div>
                            <div class="content-detail fr">

                                <span> <i>距离火车站约2.1km</i>
                                </span>

                            </div>
                        </div>
                    </div>
                </a>
            </div>
        </li>
        <li>
            <div class="pro-box ">
                <a href="#" m=点击_酒店_5-686277_1052579652>
                    <div class="img-box">
                        <img
                                src="https://m3.tuniucdn.com/filebroker/cdn/res/e5/c7/e5c7057c4cf065de5127f4fbde3a8852_w450_h300_c1_t0.jpg"/>

                        <div class="dess-txt clearfix">

                            <span class="dess-satisf fl"> <i>二星级</i>
                            </span> <span class="dess-rated fr"> <i>79</i> 条评价
                            </span>

                        </div>
                    </div>
                    <div class="content-box">
                        <p class="content-tit">中州皇冠商务酒店</p>
                        <div class="content-txt clearfix">
                            <div class="content-price fl">
                                <span class="unit">¥</span> <span class="num">88</span> <span
                                    class="text">起</span>
                            </div>
                            <div class="content-detail fr">
                                <span> <i>距离火车站约2.4km</i></span>
                            </div>
                        </div>
                    </div>
                </a>
            </div>
        </li>
    </ul>
</div>
<script src="/home/js/config.js"></script>
<script type="text/javascript">
    $(function () {
        // 获取URL参数函数
        function getQueryString(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
            var r = window.location.search.substr(1).match(reg);
            if (r != null) return unescape(r[2]);
            return null;
        }

        // 从URL获取订单ID
        var orderId = getQueryString('out_trade_no') || getQueryString('order_id') || getQueryString('order_no') || getQueryString('orderId');

        // 全局车站列表存储
        var stationList = {};

        // 加载车站列表
        function loadStationList() {
            return new Promise((resolve, reject) => {
                if (Object.keys(stationList).length > 0) {
                    resolve();
                    return;
                }

                // 从本地存储或API获取车站列表
                axios.get('/admin/train_number/findStationList')
                    .then(response => {
                        if (response.data && response.data.code === 200 && response.data.data) {
                            // 构建stationList对象，使用ID作为key，站名作为value
                            response.data.data.forEach(station => {
                                const stationId = station.stationId || station.id;
                                const stationName = station.stationName || station.station_name || station.name;
                                if (stationId && stationName) {
                                    stationList[stationId] = stationName;
                                }
                            });
                            resolve();
                        } else {
                            // 如果API失败，使用默认车站列表
                            const defaultStations = [
                                {stationId: 3, stationName: '北京西'},
                                {stationId: 15, stationName: '上海虹桥'},
                                {stationId: 1, stationName: '北京南'},
                                {stationId: 2, stationName: '上海南'},
                                {stationId: 4, stationName: '广州南'},
                                {stationId: 5, stationName: '深圳北'},
                                {stationId: 6, stationName: '杭州东'},
                                {stationId: 7, stationName: '南京南'},
                                {stationId: 8, stationName: '武汉'},
                                {stationId: 9, stationName: '成都东'},
                                {stationId: 10, stationName: '西安北'},
                                {stationId: 11, stationName: '重庆北'}
                            ];
                            defaultStations.forEach(station => {
                                stationList[station.stationId] = station.stationName;
                            });
                            resolve();
                        }
                    })
                    .catch(error => {
                        console.error('获取车站列表失败:', error);
                        // 使用默认车站列表
                        const defaultStations = [
                            {stationId: 3, stationName: '北京西'},
                            {stationId: 15, stationName: '上海虹桥'},
                            {stationId: 1, stationName: '北京南'},
                            {stationId: 2, stationName: '上海南'},
                            {stationId: 4, stationName: '广州南'},
                            {stationId: 5, stationName: '深圳北'},
                            {stationId: 6, stationName: '杭州东'},
                            {stationId: 7, stationName: '南京南'},
                            {stationId: 8, stationName: '武汉'},
                            {stationId: 9, stationName: '成都东'},
                            {stationId: 10, stationName: '西安北'},
                            {stationId: 11, stationName: '重庆北'}
                        ];
                        defaultStations.forEach(station => {
                            stationList[station.stationId] = station.stationName;
                        });
                        resolve();
                    });
            });
        }

        // 获取车站名称（通过ID）
        function getStationName(stationId) {
            if (!stationId) {
                return '';
            }

            // 尝试直接匹配
            if (stationList[stationId]) {
                return stationList[stationId];
            }

            // 尝试字符串转换匹配
            if (stationList[stationId.toString()]) {
                return stationList[stationId.toString()];
            }

            // 如果找不到匹配的，返回空字符串
            return '';
        }

        // 如果有订单ID，则从后端获取订单详情
        if (orderId) {
            // 先加载车站列表，再获取订单详情
            loadStationList().then(function() {
                // 使用axios替换jQuery AJAX
                axios.get('/home/order/getOrderInfo', {
                    params: { orderId: orderId }
                })
                    .then(function(response) {
                        var data = response.data;
                        // 检查响应数据
                        if (data.code === 200 && data.data) {
                            var orderData = data.data;
                            // 填充订单信息
                            $('.order_no').text(orderData.orderId || orderId);

                            // 车票人数：orderPassengerDTOList中的条数
                            var passengerCount = orderData.orderPassengerDTOList ? orderData.orderPassengerDTOList.length : 0;
                            $('.ticket_count').text(passengerCount);

                            // 付款金额：orderPrice
                            $('.total_price').text(orderData.orderPrice || '0.00');

                            // 获取并显示车站列表和时间信息
                            getStationList(orderData.ticket);

                            // 显示乘车人信息
                            displayPassengerInfo(orderData.orderPassengerDTOList);

                            // 更新用户名显示（优先显示订单中的乘客姓名，回退到登录用户姓名）
                            var passengerName = null;
                            if (orderData.orderPassengerDTOList && orderData.orderPassengerDTOList.length > 0) {
                                passengerName = orderData.orderPassengerDTOList[0].passengerName; // 显示第一个乘客的姓名
                            }

                            var fallbackName = localStorage.getItem('USER_NAME') || sessionStorage.getItem('USER_NAME') || localStorage.getItem('USER_ID') || sessionStorage.getItem('USER_ID');
                            if (passengerName) {
                                $('.user_name').text(passengerName);
                            } else if (orderData.userName) {
                                $('.user_name').text(orderData.userName);
                            } else if (fallbackName) {
                                $('.user_name').text(fallbackName);
                            } else {
                                $('.user_name').text('用户');
                            }
                        } else {
                            console.error('获取订单信息失败', data);
                            alert('获取订单信息失败，请稍后再试');
                            // 使用默认数据
                            loadDefaultData(orderId);
                        }
                    })
                    .catch(function(error) {
                        console.error('请求订单详情失败', error);
                        alert('获取订单信息失败，请稍后再试');
                        // 使用默认数据
                        loadDefaultData(orderId);
                    });
            });
        } else {
            // 没有订单ID，先加载车站列表，然后使用默认数据
            loadStationList().then(function() {
                loadDefaultData(orderId);
            });
        }

        // 设置用户名函数 - 确保在页面任何时候都有用户名显示
        function setUserName() {
    // 尝试从localStorage获取完整的用户信息
    var userDataStr = localStorage.getItem('USER_INFO') || sessionStorage.getItem('USER_INFO');
    if (userDataStr) {
        try {
            var userData = JSON.parse(userDataStr);
            // 优先显示name字段，如果没有name则显示username
            var userName = userData.name || userData.username || userData.userName || '用户';
            $('.user_name').text(userName);
            return;
        } catch (e) {
            console.log('用户信息解析失败:', e);
        }
    }

    // 备用方案：直接从localStorage获取用户名
    var fallbackName = localStorage.getItem('USER_NAME') || sessionStorage.getItem('USER_NAME') || localStorage.getItem('USER_ID') || sessionStorage.getItem('USER_ID');
    if (fallbackName) {
        $('.user_name').text(fallbackName);
    } else {
        $('.user_name').text('用户');
    }
}

        // 页面加载时立即设置用户名
        setUserName();

        // 获取车次号 - 直接返回trainNumberId
        function getTrainNumber(trainNumberId) {
            if (!trainNumberId) return '未知车次';
            return trainNumberId;
        }

        // 获取车站列表和处理时间显示
        function getStationList(ticket) {
            if (!ticket) return;

            // 乘车日期：ticket里的departureTime
            if (ticket.departureTime) {
                // 正确解析ISO格式的时间字符串
                var date = new Date(ticket.departureTime);
                var formattedDate = date.getFullYear() + '-' +
                    String(date.getMonth() + 1).padStart(2, '0') + '-' +
                    String(date.getDate()).padStart(2, '0');
                $('.departure_date').text(formattedDate);
            }

            // 发车时间 - 只保留小时和分钟
            if (ticket.departureTime) {
                var date = new Date(ticket.departureTime);
                var formattedTime = String(date.getHours()).padStart(2, '0') + ':' +
                    String(date.getMinutes()).padStart(2, '0');
                $('.start_time').text(formattedTime);
            }

            // 到站时间 - 只保留小时和分钟，考虑第二天的情况
            if (ticket.arrivalTime && ticket.departureTime) {
                var arrivalDate = new Date(ticket.arrivalTime);
                var departureDate = new Date(ticket.departureTime);
                var formattedTime = String(arrivalDate.getHours()).padStart(2, '0') + ':' +
                    String(arrivalDate.getMinutes()).padStart(2, '0');

                // 检查是否跨天
                var departureDay = departureDate.getDate();
                var arrivalDay = arrivalDate.getDate();
                var departureHour = departureDate.getHours();
                var arrivalHour = arrivalDate.getHours();

                // 如果到达日期大于出发日期，或者在同一天但到达时间早于出发时间（如23:00出发，01:00到达）
                if (arrivalDay > departureDay || (arrivalDay === departureDay && arrivalHour < departureHour)) {
                    formattedTime += '(+1)';
                }

                $('.arrive_time').text(formattedTime);
            }

            // 始发站名称
             if (ticket.startStationName) {
                 $('.start_station').text(ticket.startStationName);
             } else if (ticket.startStationId) {
                 var startStation = getStationName(ticket.startStationId);
                 $('.start_station').text(startStation || '未知站点');
             } else {
                 $('.start_station').text('未知站点');
             }

             // 到达站名称
             if (ticket.arrivalStationName) {
                 $('.end_station').text(ticket.arrivalStationName);
             } else if (ticket.arrivalStationId) {
                 var endStation = getStationName(ticket.arrivalStationId);
                 $('.end_station').text(endStation || '未知站点');
             } else {
                 $('.end_station').text('未知站点');
             }

            // 车次 - 支持trainNumberId转换为实际车次号
            if (ticket.trainNumber) {
                $('.train_number').text(ticket.trainNumber);
            } else if (ticket.trainNumberId) {
                // 使用trainNumberId获取车次号
                $('.train_number').text(getTrainNumber(ticket.trainNumberId));
            }
        }

        // 显示乘车人信息 - 不显示性别
        function displayPassengerInfo(passengerList) {
            if (!passengerList || passengerList.length === 0) {
                $('.foot').html('<span style="color: gray;">暂无乘车人信息</span>');
                return;
            }

            var passengerHtml = '';
            passengerList.forEach(function (passenger, index) {
                var carriageSeat = '';
                if (passenger.carriageNumber && passenger.seatNumber) {
                    carriageSeat = passenger.carriageNumber + '车' + passenger.seatNumber + '号';
                }

                // 只显示乘客名称和座位信息
                passengerHtml += '<span style="margin-left: 3px; padding-right: 13px;">' +
                    passenger.passengerName + '：<span style="color:#FF4500">' +
                    carriageSeat + '</span></span>';
            });

            $('.foot').html('<span style="color: gray; font-weight: 800;">' + passengerHtml + '</span>');
        }

        // 加载默认数据
        function loadDefaultData(orderId) {
            // 模拟数据（作为默认值）
            var date = new Date();
            var formattedDate = date.getFullYear() + '-' +
                String(date.getMonth() + 1).padStart(2, '0') + '-' +
                String(date.getDate()).padStart(2, '0');

            $('.order_no').text(orderId || "20240420123456789");
            $('.ticket_count').text(2);
            $('.total_price').text('280.00');
            $('.departure_date').text(formattedDate);
            $('.start_time').text('08:30');
            $('.arrive_time').text('12:45');
            $('.start_station').text('北京西');
            $('.end_station').text('上海虹桥');
            $('.train_number').text('G101');
            // 显示默认乘车人信息
            var defaultPassengers = [
                {passengerName: '老马', sex: 1, carriageNumber: '1', seatNumber: '1A'},
                {passengerName: '老马', sex: 1, carriageNumber: '1', seatNumber: '1B'}
            ];
            displayPassengerInfo(defaultPassengers);

            // 更新用户名显示为默认乘客姓名
            $('.user_name').text('老马');
        }

        // 加载顶部导航栏 - 使用jQuery的load方法
        $(document).ready(function() {
            // 使用绝对路径加载header
            $.ajax({
                url: '/home/header.html',
                type: 'GET',
                success: function(response) {
                    $('#header').html(response);
                    // 如果header中有JavaScript需要执行
                    if (response.indexOf('<script') !== -1) {
                        // 提取并执行脚本
                        var scripts = $(response).filter('script');
                        scripts.each(function() {
                            if (this.src) {
                                // 外部脚本
                                $.getScript(this.src);
                            } else {
                                // 内联脚本
                                eval($(this).html());
                            }
                        });
                    }
                },
                error: function(xhr, status, error) {
                    console.log('加载header失败:', status, error);
                    // 提供备用内容
                    $('#header').html('<div style="background:#333;color:white;padding:10px;text-align:center;">页面加载中...</div>');
                }
            });

            // 使用绝对路径加载footer
            $.ajax({
                url: '/home/footer.html',
                type: 'GET',
                success: function(response) {
                    $('#footer').html(response);
                },
                error: function(xhr, status, error) {
                    console.log('加载footer失败:', status, error);
                    // 提供备用内容
                    $('#footer').html('<div style="background:#000;color:#999;padding:30px;text-align:center;">页面加载中...</div>');
                }
            });
        });
    });
</script>

<!--引入底部footer.html文件-->
<div id="footer"></div>

</body>
</html>

